package com.musteri;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Kasa {
	Map<Musteri, Integer> kasaMap = new HashMap();

	public static void main(String[] args) {
		Kasa k = new Kasa();

		List<Musteri> musteriList = new ArrayList();
		musteriList.add(new Musteri("M1", 10));
		musteriList.add(new Musteri("M2", 5));
		musteriList.add(new Musteri("M2", 140));
		musteriList.add(new Musteri("M3", 5));
		musteriList.add(new Musteri("M1", 90));

		for (Musteri musteri : musteriList) {
			k.kasa(musteri);
		}

		System.out.println(k.kasaMap);

	}

	void kasa(Musteri m) {
		if (kasaMap.get(m) == null)
			kasaMap.put(m, m.getTutar());
		else
			kasaMap.put(m, kasaMap.get(m) + m.getTutar());
	}
}
